//
//  HRHRSearchResultCell.m
//  Hear
//
//  Created by mac on 2017/12/4.
//  Copyright © 2017年 mac. All rights reserved.
//

#import "HRHRSearchResultCell.h"
#import "HRCoverImageModel.h"
@interface HRHRSearchResultCell()
@property (weak, nonatomic) IBOutlet UIImageView *iconImageView;
@property (weak, nonatomic) IBOutlet UILabel *nickNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *distanceLabel;
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;
@property (weak, nonatomic) IBOutlet UIButton *sexButton;
@property (weak, nonatomic) IBOutlet UIButton *fromButton;

@end
@implementation HRHRSearchResultCell

-(void)setInfoModel:(HRUpdataUserInfoModel *)infoModel{
    WeakSelf
    if (infoModel.UserPictureName.length < 10){
        [HRCoverImageModel OriginImage:[UIImage imageNamed:infoModel.UserPictureName] scaleToSize:CGSizeMake(75, 75) callBackOriginImage:^(UIImage *originImage) {
            weakSelf.iconImageView.image = originImage;
        }];
        self.iconImageView.backgroundColor = [UIColor colorWithHexString:infoModel.UserPictureBackgroundColor];
    }else{
        [self.iconImageView.layer setImageWithURL:[NSURL URLWithString:infoModel.UserPictureName] placeholder:[UIImage imageNamed:@""]];
    }
    self.nickNameLabel.text = infoModel.NickName;
    self.distanceLabel.text = infoModel.DistanceText;
    self.timeLabel.text = infoModel.ActiveText;
    
    if ([infoModel.Sex intValue]==1){
        self.sexButton.layer.borderColor = CustomColor(60, 130, 200, 1).CGColor;
        [self.sexButton setImage:[UIImage imageNamed:@"男"] forState:0];
        [self.sexButton setTitleColor:CustomColor(60, 130, 200, 1) forState:0];
    }else{
        self.sexButton.layer.borderColor = CustomColor(240, 90, 140, 1).CGColor;
        [self.sexButton setTitleColor:CustomColor(240, 90, 140, 1) forState:0];
        [self.sexButton setImage:[UIImage imageNamed:@"女"] forState:0];
    }
    [self.sexButton setTitle:infoModel.UserGroup forState:0];
    
    self.fromButton.hidden = !infoModel.UserSoundUrl.length;
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.iconImageView.layer.cornerRadius = self.iconImageView.width/2;
    self.iconImageView.clipsToBounds = YES;
    self.sexButton.layer.borderWidth = 1;
    self.sexButton.layer.cornerRadius = 3;
    self.fromButton.layer.borderWidth = 1;
    self.fromButton.layer.cornerRadius = 3;
    self.fromButton.layer.borderColor = BlueColor.CGColor;

}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
